A class for primitive type (int, double, boolean)

Integer and Double = classes
Vs.
int and double = primitive types

int and double cannot be used in ArrayList.

Wrapper Classes-
  • Integer
  • Double
  • Boolean

These enable methods to be used with primitive types. This is possible because each primitive type now has its own type. Another great feature is that they can now be utilized within an ArrayList.

Methods-
Integer x = new Integer(7);
Integer x = 5;
x.equals(10);  //returns true/false
  //cannot use ==
x.compareTo(10);
  //cannot use >, <, >=, <=
  //returns 1(x>__), 0(x=__), or -1(x<__)
 
To break this down:
Integer x = new Integer(7);
This creates the Integer wrapper class in slot 7
Integer x = 5;
This sets x equal to 5.
x.equals(10);
In this case, it would return false, because 5 =/= 10.
Also, as the comment states, you CANNOT use ==, <=,>=, or any of the others. This is already done, thanks to the compareTo method. This method is explained in the comment.